package mest.util;

import lombok.Builder;

@Builder
public class ResultObj {

	/**
     * 
     */
    private static final long serialVersionUID = 13235352523234L;
    
    /**
	 * 0,成功
	 */
    public static final int CODE_SUCCESS = 0;
	/**
	 * 1,系统出错啦
	 */
	public static final int CODE_EXCEPTION = 1;
	/**
	 * 2,连接失败
	 */
	public static final int CODE_CONN_ERR = 2;
	/**
	 * 3,缺少参数
	 */
	public static final int CODE_PARAM_EMPTY =3;
	/**
	 * 4,参数格式非法
	 */
	public static final int CODE_PAPAM_ILLEGAL =4;
	/**
	 * 5,数据缺失
	 */
	public static final int CODE_DATA_EMPTY = 5;
	/**
	 * 6,没有找到匹配的数据
	 */
	public static final int CODE_DATA_NOT_FOUND = 6;
	/**
	 * 7,没有找到匹配的条件
	 */
	public static final int CODE_CONDITION_NOT_MATCH = 7;
	/**
	 * 8,数据格式非法
	 */
	public static final int CODE_DATA_ILLEGAL = 8;
	/**
	 * 9,数据格式非法
	 */
	public static final int CODE_DATA_ERROR = 9;
	/**
	 * 10,操作失败
	 */
	public static final int CODE_ERROR = 10;
	/**
	 * 11,当前版本不支持的操作
	 */
	public static final int CODE_OPERATION_UNSUPPORTED = 11;
	/**
	 * 12,需要登录
	 */
	public static final int CODE_LOGIN_REQUIRED = 12;
	/**
	 * 13,服务器未启动
	 */
	public static final int CODE_SERVER_NOT_START = 13;
	/**
	 * 14,token验证不通过
	 */
	public static final int CODE_TOKEN_ILLEGAL = 14;
	/**
	 * 15,服务器维护中
	 */
	public static final int CODE_SERVER_RESTRICTED = 15;

	/**
	 * 成功
	 */
    public static final String SUCCESS = "成功!";
	/**
	 * 提交成功
	 */
    public static final String SUBMIT_SUCCESS = "提交成功!";
    /**
	 * 调取成功
	 */
    public static final String SELECT_SUCCESS = "调取成功!";
    /**
	 * 新建成功
	 */
    public static final String INSERT_SUCCESS = "新建成功!";
    /**
	 * 更新成功
	 */
    public static final String UPDATE_SUCCESS = "更新成功!";
    
    public static final String DELETE_SUCCESS = "删除成功!";
    
    public static final String AUTH_SUCCESS = "授权成功!";
    
    public static final String AUTH_FAILED = "授权失败!";
    
    public static final String LOGIN_SUCCESS = "登陆成功!";
    
    public static final String EXIT_SUCCESS = "退出成功!";
    /**
     * 请重新登录!
     */
    public static final String SESSION_INVALIDE = "请重新登录!";

    public static final String PARAMETER_INVAILD = "参数不合法!";

    public static final String SAVE_FAIL = "保存失败!";

    public static final String FILE_PARSE_FAIL = "文件解析失败!";

    public static final String FILE_TYPE_ILLEGAL = "文件类型不合法!";

    public static final String FILE_NOT_EXISTI = "文件不存在!";

    public static final String ROW_DUPLICATE = "Excel中含重复id的列!";
    /**
     * 发生错误!
     */
    public static final String ERROR = "发生错误!";
	/**
	 * 服务异常,请联系系统管理员！
	 */
    public static final String ERROR2 = "服务异常,请联系系统管理员！";
    
    /**
     *  返回码
     */
    protected int code;

    /**
     * 返回信息
     */
    protected String msg;

    /**
     * 数据量
     */
    protected Integer count;
    
    /**
     * 具体数据
     */
    protected Object data;
    
    public ResultObj() {
        
    }
    
    public ResultObj(int code, String msg,Integer count, Object data) {
		super();
		this.code = code;
		this.msg = msg;
		this.count = count;
		this.data = data;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}
	
    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static ResultObj createSuccess(){
        return new ResultObj(ResultObj.CODE_SUCCESS,ResultObj.SUCCESS,0,"");
    }

    public static ResultObj createError(){
        return new ResultObj(ResultObj.CODE_ERROR,ResultObj.ERROR2,0,"");
    }

    public static ResultObj createInteralError(String msg){
        return new ResultObj(ResultObj.CODE_ERROR,msg,0,"");
    }

    public static ResultObj createSuccessMsg(String msg){
        return new ResultObj(ResultObj.CODE_SUCCESS,msg,0,"");
    }

    public static ResultObj createErrorMsg(String msg){
        return new ResultObj(ResultObj.CODE_ERROR,msg,0,"");
    }

    public static ResultObj createSuccessData(Object data){
        return new ResultObj(ResultObj.CODE_SUCCESS,ResultObj.SUCCESS,0,data);
    }

    public static ResultObj createErrorData(Object data){
        return new ResultObj(ResultObj.CODE_ERROR,ResultObj.ERROR2,0,data);
    }

    public static ResultObj createSuccess(String msg,Object data){ return new ResultObj(ResultObj.CODE_SUCCESS,msg,0,data); }

    public static ResultObj createError(String msg,Object data){ return new ResultObj(ResultObj.CODE_ERROR,msg,0,data); }

}
